<script>
APP.prestasiPelanggaranPerBidang = {
	action: 'proc/admin/prestasiPelanggaranPerBidang.php',
	periode1: null,
	periode2: null,
		
	load_graph: function (form){
		var showImage = function(){
			var img = $('graphContainer').getElement('img');
			if (img == null) return;
			if (img.complete) $('graphContainer').tween('opacity',1);	
			else showImage.delay(1000);
		}
		
		$('graphContainer').tween('opacity',0);	
		FBModal_loading("Loading...", "Generating graph", true, true);
		form.set('action',APP.prestasiPelanggaranPerBidang.action).set('send',{
			onSuccess: function(res){
				//alert(res);
				if (res) {
					res = res.replace(/href/gi,'onclick');
					$('graphContainer').empty().set('html', res)
						.getElements('area').each(function(item){
							item.addEvent('click', function(e){ new Event(e).stop(); })
								.href="#";
						});
				}
				else{
					$('graphContainer').empty();
				}
				showImage.delay(1000);
				FBModal_hide();
			}		 
		}).send();
		
	},
	
	load_drillGraph: function (data){
		var jenis = data.type==1? 'prestasi' : 'pelanggaran';
		var proc ="proc=graph-drill&achievBidang="+data.achievBidang+"&startPeriode="+data.startPeriode+
					"&endPeriode="+data.endPeriode+"&jenis="+jenis ;
		FBModal_show2( APP.prestasiPelanggaranPerBidang.action , 'post', proc, true, true, null);
	}
	
};
	window.addEvent('domready', function(){
		var form = $('prestasiPelanggaranPerBidang-form');

		APP.prestasiPelanggaranPerBidang.periode1 = dtpicker_attach0(form.periode1, {
			timePicker:false, format: 'F-Y', 
			maxDate: { date: <?php echo time()?>, format: 'U' },
			onClose: function(){ 
				APP.prestasiPelanggaranPerBidang.periode2.options.minDate = {
					date:APP.prestasiPelanggaranPerBidang.periode1.attachTo.value, 
					format:'U'};
				APP.prestasiPelanggaranPerBidang.periode2.formatMinMaxDates();
				APP.prestasiPelanggaranPerBidang.load_graph(form);
			}
		});
		APP.prestasiPelanggaranPerBidang.periode2 = dtpicker_attach0(form.periode2, {
			maxDate:{ date: <?php echo time()?>, format: 'U' }, 
			timePicker:false, format: 'F-Y', onClose: function(){ 
				APP.prestasiPelanggaranPerBidang.load_graph(form); 
			} 
		});
		APP.prestasiPelanggaranPerBidang.periode2.options.minDate = {
			date:APP.prestasiPelanggaranPerBidang.periode1.attachTo.value, 
			format:'U'};
	});
</script>
<form id="prestasiPelanggaranPerBidang-form" name="prestasiPelanggaranPerBidang-form" method="post">
<input type="hidden" name="proc" value="graph" />
<table width="100%" border="0">
<tr>
    <td align="right" valign="top" width="100">Departemen : </td>
	<td align="left">
		<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border:1px solid #3366CC;" bgcolor="#FFFFFF">
		<?php $DEP = mysql_query("SELECT ACHIEV_BIDANG FROM `prestasipelanggaran` GROUP BY ACHIEV_BIDANG"); 
			  $row=true; ?>
		<?php while ($row):?>
		<tr <?php echo tag_zebra($z++)?>>
			<?php for($i=0; $i<3; $i++): ?>
			<?php if ($row = mysql_fetch_assoc($DEP)) : ?>
			<td>
			<input name="achievBidang[]" type="checkbox" value="<?php echo $row['ACHIEV_BIDANG']?>" onChange="APP.prestasiPelanggaranPerBidang.load_graph($(this).getParent('form'))"/>
			<span class="marginL5"><?php echo $row['ACHIEV_BIDANG']?></span>
			</td>
			<?php else: ?><td></td>
			<?php endif;?>
			<?php endfor;?>
		</tr>
		<?php endwhile; ?>
		</table>
	</td>
</tr>
<tr>
    <td align="right">Periode : </td>
    <td><input type="text" name="periode1" value="<?php echo time()?>" /> - <input name="periode2" type="text" value="<?php echo time()?>" /></td>
</tr>
</table>
</form>
